function pay(money,title,resfun){
    wx.request({
      url: 'http://xwz.wyuek.com/Wxpay/example/jsapi.php',
      data: {
        openId: wx.getStorageSync("openid"),
        money: 0.01
      },
      success: function (response) {
        var miyao = response.data.miyao;
        var lghtime = response.data.lghtime
        var appId = response.data.appid;
        var timeStamp = (Date.parse(new Date()) / 1000).toString();
        var pkg = 'prepay_id=' + response.data.prepay_id;
        var payid = response.data.prepay_id;
        var nonceStr = response.data.nonce_str;
        var md5 = require('../utils/md5.js');
        var paySign = md5.hex_md5('appId=' + appId + '&nonceStr=' + nonceStr + '&package=' + pkg + '&signType=MD5&timeStamp=' + timeStamp + "&key=" + miyao).toUpperCase();

        wx.requestPayment({
          'timeStamp': timeStamp,
          'nonceStr': nonceStr,
          'package': pkg,
          'signType': 'MD5',
          'paySign': paySign,
          'success': function (res) {
            if (res.errMsg == "requestPayment:ok") {
              //todo支付成功之后的逻辑问题
              resfun(res)
            } else {
              //tode支付失败之后逻辑问题
            }
          },
          'fail': function (res) {
            wx.showToast({
              title: '支付失败',
              icon: 'loading',
              duration: 10000,
              mask: true
            })
            setTimeout(function () {
              wx.hideLoading()
            }, 1000)
          }
        });
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
    });
}

module.exports = {
  pay: pay,
}